Calendar All Tests
Current file: /home/estudydev/workspace/eStudy_svn/web/calendar/classes/export/class.database.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
60.00 %60.00%
60.00% 3 / 5
50.00 %50.00%
50.00% 12 / 24
 
Database
100.00 %100.00%
100.00% 1 / 1
60.00 %60.00%
60.00% 3 / 5
50.00 %50.00%
50.00% 12 / 24
 public function Database($userID)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 4 / 4
 public function fetchEvents()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 10
 public function authenticate($userID, $token)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function hash()
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 3 / 3
 public function iCalendarURL()
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 5 / 5


       1                 : <?php                                                                                
       2                 : if (!defined("PATH_TO_ROOT")) define("PATH_TO_ROOT", "../../../");                   
       3                 :                                                                                      
       4                 : class Database {                                                                     
       5                 :                                                                                      
       6                 :     private $db;                                                                     
       7                 :     private $userID;                                                                 
       8                 :                                                                                      
       9                 :     public function Database( $userID ) {                                            
      10              14 :         global $db;                                                                  
      11              14 :         $this->db        = $db;                                                      
      12              14 :         $this->userID     = (int)$userID;                                            
      13              14 :     }                                                                                
      14                 :                                                                                      
      15                 :     public function fetchEvents() {                                                  
      16               0 :         $user     = "SELECT eventID FROM calendar_user WHERE userID = $this->userID";
      17                 :         $team     = "SELECT eventID FROM calendar_courses LEFT JOIN user_course "    
      18                 :                         . "ON calendar_courses.coursesID = user_course.courseID "    
      19               0 :                         . "WHERE user_course.userID = $this->userID";                
      20                 :         $course = "SELECT eventID FROM calendar_teams LEFT JOIN user_team "          
      21                 :                         . "ON calendar_teams.teamsID = user_team.team_id "           
      22               0 :                         . "WHERE user_team.user_id = $this->userID";                 
      23               0 :         $foyer  = "SELECT eventID FROM calendar_courses WHERE coursesID=0";          
      24                 :                                                                                      
      25                 :         $sql     = "SELECT * FROM calendar WHERE eventid IN ( "                      
      26               0 :             . $user . " UNION "                                                      
      27               0 :             . $team . " UNION "                                                      
      28               0 :             . $course . " UNION "                                                    
      29               0 :             . $foyer . ") "                                                          
      30               0 :             . "ORDER BY eventtime ASC";                                              
      31                 :                                                                                      
      32               0 :         return $this->db->get_results($sql);                                         
      33                 :     }                                                                                
      34                 :                                                                                      
      35                 :     public function authenticate( $userID, $token ) {                                
      36               0 :         if ( $token === $this->hash($userID) ) return true;                          
      37                 :                                                                                      
      38               0 :         return false;                                                                
      39                 :     }                                                                                
      40                 :                                                                                      
      41                 :     public function hash() {                                                         
      42               2 :         $sql = "SELECT Login,regdate,policy_read FROM user WHERE ID=$this->userID";  
      43               2 :         $result = $this->db->get_row($sql);                                          
      44               2 :         return sha1($result->Login . $result->policy_read . $result->regdate);       
      45                 :     }                                                                                
      46                 :                                                                                      
      47                 :     public function iCalendarURL() {                                                 
      48               1 :         $sql = "SELECT value FROM settings WHERE name='emod_wsdlpath'";              
      49               1 :         return $this->db->get_var($sql)                                              
      50                 :             . "/calendar/icalendar.php?user="                                        
      51               1 :             . $_SESSION['userid']                                                    
      52               1 :             . "&amp;token="                                                          
      53               1 :             . $this->hash();                                                         
      54                 :     }                                                                                
      55                 : }                                                                                    

Generated by PHPUnit 3.2.21 and Xdebug 2.0.3 at Thu Nov 26 17:01:15 CET 2009.